<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>3dchess: ServiceDispatcher Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">3dchess
   </div>
   <div id="projectbrief">Basic chess application with OpenGL graphics and AI</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="#pri-attribs">Private Attributes</a> &#124;
<a href="class_service_dispatcher-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">ServiceDispatcher Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Provides functionality for safely running operations in a thread.  
 <a href="class_service_dispatcher.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_service_dispatcher_8h_source.html">ServiceDispatcher.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for ServiceDispatcher:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_service_dispatcher.png" usemap="#ServiceDispatcher_map" alt=""/>
  <map id="ServiceDispatcher_map" name="ServiceDispatcher_map">
<area href="class_observer_dispatcher_proxy.html" title="Proxy for transporting AbstractGameObserver events between threads. " alt="ObserverDispatcherProxy" shape="rect" coords="0,56,160,80"/>
<area href="class_player_dispatcher_proxy.html" title="Proxy for transporting AbstractGamePlayer events between threads. " alt="PlayerDispatcherProxy" shape="rect" coords="170,56,330,80"/>
<area href="class_service_dispatcher_thread.html" title="Provides functionality for safely running operations in a thread. " alt="ServiceDispatcherThread" shape="rect" coords="340,56,500,80"/>
<area href="class_console_player.html" title="Class which takes human player interaction from a console. " alt="ConsolePlayer" shape="rect" coords="255,112,415,136"/>
<area href="class_dummy_player.html" title="Player implementation which takes random turns after random amounts of time. " alt="DummyPlayer" shape="rect" coords="425,112,585,136"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a523e6f7dc4e533b0b7938cec62c55c6d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_service_dispatcher.html#a523e6f7dc4e533b0b7938cec62c55c6d">poll</a> ()</td></tr>
<tr class="memdesc:a523e6f7dc4e533b0b7938cec62c55c6d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Replays all posted functions in the calling thread.  <a href="#a523e6f7dc4e533b0b7938cec62c55c6d">More...</a><br/></td></tr>
<tr class="separator:a523e6f7dc4e533b0b7938cec62c55c6d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a51360fc052cab5a9bad17fd586081091"><td class="memTemplParams" colspan="2">template&lt;typename Function &gt; </td></tr>
<tr class="memitem:a51360fc052cab5a9bad17fd586081091"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_service_dispatcher.html#a51360fc052cab5a9bad17fd586081091">post</a> (Function &amp;&amp;function)</td></tr>
<tr class="memdesc:a51360fc052cab5a9bad17fd586081091"><td class="mdescLeft">&#160;</td><td class="mdescRight">Store a given function.  <a href="#a51360fc052cab5a9bad17fd586081091">More...</a><br/></td></tr>
<tr class="separator:a51360fc052cab5a9bad17fd586081091"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1723f2592299a9bf4ac9e9557929cf52"><td class="memTemplParams" colspan="2">template&lt;typename Function &gt; </td></tr>
<tr class="memitem:a1723f2592299a9bf4ac9e9557929cf52"><td class="memTemplItemLeft" align="right" valign="top">auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="class_service_dispatcher.html#a1723f2592299a9bf4ac9e9557929cf52">postPromise</a> (Function &amp;&amp;function) -&gt; decltype(std::promise&lt; typename std::result_of&lt; Function()&gt;::type &gt;().get_future())</td></tr>
<tr class="memdesc:a1723f2592299a9bf4ac9e9557929cf52"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stores a given function and returns a future on its return value.  <a href="#a1723f2592299a9bf4ac9e9557929cf52">More...</a><br/></td></tr>
<tr class="separator:a1723f2592299a9bf4ac9e9557929cf52"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a92d6309517ea11b6d646e787865c000a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_service_dispatcher.html#a92d6309517ea11b6d646e787865c000a">run</a> ()</td></tr>
<tr class="memdesc:a92d6309517ea11b6d646e787865c000a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Runs underlying boost asio io_service.  <a href="#a92d6309517ea11b6d646e787865c000a">More...</a><br/></td></tr>
<tr class="separator:a92d6309517ea11b6d646e787865c000a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad8ad1909afe414cd27e21c8cdd214c6c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad8ad1909afe414cd27e21c8cdd214c6c"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_service_dispatcher.html#ad8ad1909afe414cd27e21c8cdd214c6c">resetWork</a> ()</td></tr>
<tr class="memdesc:ad8ad1909afe414cd27e21c8cdd214c6c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Drops queued functions. <br/></td></tr>
<tr class="separator:ad8ad1909afe414cd27e21c8cdd214c6c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7bf54f65ee49a65d344581078d0a61b6"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7bf54f65ee49a65d344581078d0a61b6"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_service_dispatcher.html#a7bf54f65ee49a65d344581078d0a61b6">stopService</a> ()</td></tr>
<tr class="memdesc:a7bf54f65ee49a65d344581078d0a61b6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Stops underlying service. <br/></td></tr>
<tr class="separator:a7bf54f65ee49a65d344581078d0a61b6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-attribs"></a>
Private Attributes</h2></td></tr>
<tr class="memitem:a56acce42382609df43dee29818dee81b"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a56acce42382609df43dee29818dee81b"></a>
boost::asio::io_service&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_service_dispatcher.html#a56acce42382609df43dee29818dee81b">m_service</a></td></tr>
<tr class="memdesc:a56acce42382609df43dee29818dee81b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Object providing event loop queuing and dispatching functionality. <br/></td></tr>
<tr class="separator:a56acce42382609df43dee29818dee81b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a530a37d146eb4451741fb35971d69901"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a530a37d146eb4451741fb35971d69901"></a>
std::unique_ptr<br class="typebreak"/>
&lt; boost::asio::io_service::work &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_service_dispatcher.html#a530a37d146eb4451741fb35971d69901">m_work</a></td></tr>
<tr class="memdesc:a530a37d146eb4451741fb35971d69901"><td class="mdescLeft">&#160;</td><td class="mdescRight">Work object preventing service run loop from exiting on dry queue. <br/></td></tr>
<tr class="separator:a530a37d146eb4451741fb35971d69901"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Provides functionality for safely running operations in a thread. </p>
<p>For components running on different threads it is essential to safely transport events between them. Without any additional precautions functions will execute on the thread they are called.</p>
<p>This dispatcher can store functions in a thread-safe way and replay them once its poll method is called in the customers thread. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a523e6f7dc4e533b0b7938cec62c55c6d"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void ServiceDispatcher::poll </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Replays all posted functions in the calling thread. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="class_service_dispatcher.html#a51360fc052cab5a9bad17fd586081091" title="Store a given function. ">post</a> </dd>
<dd>
<a class="el" href="class_service_dispatcher.html#a1723f2592299a9bf4ac9e9557929cf52" title="Stores a given function and returns a future on its return value. ">postPromise</a> </dd></dl>

</div>
</div>
<a class="anchor" id="a51360fc052cab5a9bad17fd586081091"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Function &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void ServiceDispatcher::post </td>
          <td>(</td>
          <td class="paramtype">Function &amp;&amp;&#160;</td>
          <td class="paramname"><em>function</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Store a given function. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">function</td><td>Function to store and later replay. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a1723f2592299a9bf4ac9e9557929cf52"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename Function &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">auto ServiceDispatcher::postPromise </td>
          <td>(</td>
          <td class="paramtype">Function &amp;&amp;&#160;</td>
          <td class="paramname"><em>function</em></td><td>)</td>
          <td> -&gt; decltype(std::promise&lt;typename std::result_of&lt;Function()&gt;::type&gt;().get_future())</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Stores a given function and returns a future on its return value. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">function</td><td>Function to store and later replay. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Future on result of given function. </dd></dl>

</div>
</div>
<a class="anchor" id="a92d6309517ea11b6d646e787865c000a"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void ServiceDispatcher::run </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Runs underlying boost asio io_service. </p>
<dl class="section note"><dt>Note</dt><dd>Will block until work is completed. </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>S:/dev/3dchess/src/logic/threading/<a class="el" href="_service_dispatcher_8h_source.html">ServiceDispatcher.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Mar 9 2014 23:13:00 for 3dchess by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
